package com.godyhm.example.userendport.Protocol;

public class Protocol{
//	public static byte PROTOCOL_HEADER_V1_SIZE = 8;
//	public static byte PROTOCOL_HEADER_V2_SIZE = 12;
//
//	public static byte PROTOCOL_VERSION_1 = 0x01;
//	public static byte PROTOCOL_VERSION_2 = 0x02;
	
	public static final byte PROTOCOL_HEADER_TYPE_SEND=0x01;
	public static final byte PROTOCOL_HEADER_TYPE_REACT=0x02;
	/**
	 * sender frame start 
	 * */
	public static final short PROTOCOL_HEADER_SENDER_START = (short)0xA5A5;
	/**
	 * start of react frame
	 * */
	public static final short PROTOCOL_HEADER_REACT_START = (short)0x5A5A;
	
	
	public static final byte PROTOCOL_HEADER_SENDER_SIZE = 17;
	public static final byte PROTOCOL_HEADER_REACT_SIZE = 13;
	/**
	 * protocol version 
	 * */
	public static final byte PROTOCOL_VERSION = 0x01;
	/**
	 * compress flag
	 * */
	public static final boolean COMPRESS_OFF = false;

	/**
	 * frame type
	 * */
	public static final byte FRAME_TYPE_CONTROL = 0x00;
	public static final byte FRAME_TYPE_COMMON = 0x01;
	public static final byte FRAME_TYPE_BINARY= 0x02;

	/**
	 * frame sub type
	 * */
//	public static final byte FRAME_TYPE_CONTROL_HEART_BEAT = 0x00;
	public static final byte FRAME_TYPE_CONTROL_START_SESSION=0x00;
//	public static final byte FRAME_TYPE_CONTROL_END_SESSION=0x02;
	
	public static final byte FRAME_TYPE_COMMON_SINGLE = 0x00;
	public static final byte FRAME_TYPE_COMMON_CONSECUTIVE = 0x01;
	
	public static final byte FRAME_TYPE_BINARY_AUDIO= 0x00;
	public static final byte FRAME_TYPE_BINARY_VIDEO= 0x01;
	public static final byte FRAME_TYPE_BINARY_IMAGE= 0x02;
	
	/**
	 * connection type
	 * */
	public static final byte FRAME_TYPE_CONNECTION_TYPE_TRANSMISSION_START=0x00;
	public static final byte FRAME_TYPE_CONNECTION_TYPE_DATA_TRANSFER=0x01;
	public static final byte FRAME_TYPE_CONNECTION_TYPE_TRANSMISSION_END=0x02;
	
	
	/**
	 *  Maximum of consecutive frame numbers after which count has to roll over to 0x01
	 */ 
	public static final int FRAME_SEQUENCE_MAX_VALUE = 0xFFFF;
	
	/**
	 * Maximun frame raw data size 
	 * */
	public static final int MAXIMUM_FRAME_RAW_DATA_SIZE = 0x7fffffff;

//	//Marks last frame in multi-frame message.
//	public static int FRAME_DATA_LAST_FRAME = 0x00;
//	//Size of first frame in multi-frame message.
//	public static int FIRST_FRAME_DATA_SIZE = 0x08;
	
	public enum RESULT_CODE{
		RESULT_OK(1),
		RESULT_FAIL(2),
		RESULT_NUMBER_BUSY(3),
		RESULT_CONNECTION_LOST(4),
		RESULT_DISCONNECTED(5),
		RESULT_NOTFOUND(6),
		RESULT_TIMEOUT(7),
		RESULT_WRONG_SEQUENCE(8),
		RESULT_AGAIN(9),
		RESULT_WRONG_FRAME_SEQUENCE(10),
		RESULT_IN_PROGRESS(11),
		RESULT_REASSIGN(12),
		RESULT_XML_PARSING(13),
		RESULT_RESEND_ACK(14),
		RESULT_DEFRERRED(15),
		RESULT_SUM_CHECK_FAIL(16),
		RESULT_UNKNOWN(255);
		
		private final byte value;
		
        public byte getValue() {
            return value;
        }
        RESULT_CODE(int value) {
            this.value = (byte)value;
        } 
	};
}

